import Vue from 'vue'

import VRouter from 'vue-router'

Vue.use(VRouter)

//路由需要的模块

//  import Home from '@/components/home'
//  import News from '@/components/new'


// export default new VRouter({
// 	routes:[
// 		{path:'/',component:Home},
// 		{path:'/news',component:News}
// 	]
// })

export default new VRouter({
	mode:'history',//去掉路由中的#
	routes:[
		{
			path:'/',
			redirect:'/home'
		},
		{
			path:'/home',
			component:resolve=>{require(['@/components/home'],resolve)}
		},
		{
			path:'/router',
			component:resolve=>{require(['@/page/router'],resolve)},
			redirect:'/router/child',
			beforeEnter:(to,from,next)=>{
				console.log(to)
				console.log(from)
				next()
			},
			children:[
				{name:'par',path:'par/:id',component:resolve=>{require(['@/page/router/params'],resolve)}},
				{name:'child',path:'child',component:resolve=>{require(['@/page/router/child'],resolve)}}
			]
		},
		{
			path:'/com',
			component:resolve=>{require(['@/page/com/comPage'],resolve)},
			redirect:'/com/base',
			children:[
				{name:'base',path:'base',component:resolve=>{require(['@/page/com/child1'],resolve)}},
				{name:'son',path:'son',component:resolve=>{require(['@/page/com/son'],resolve)}},
				{name:'toParent',path:'toParent',component:resolve=>{require(['@/page/com/toParent'],resolve)}},
				{name:'is',path:'is',component:resolve=>{require(['@/page/com/is'],resolve)}},
				{name:'slot',path:'slot',component:resolve=>{require(['@/page/com/slot'],resolve)}},
				{name:'slotName',path:'slotName',component:resolve=>{require(['@/page/com/slotName'],resolve)}},
				{name:'star',path:'star',component:resolve=>{require(['@/page/com/starPage'],resolve)}}
			]

		}

	]
})
